package org.thanos.demo.api.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.thanos.demo.core.dao.ConfigPropertiesDao;
import org.thanos.demo.core.entity.ConfigProperties;

import java.util.List;

@RestController
public class ConfigPropertiesController {

    @Autowired
    private ConfigPropertiesDao configPropertiesDao;

    @GetMapping(value = "/configs")
    public List<ConfigProperties> configs() {
        return configPropertiesDao.queryAll();
    }

    @GetMapping(value = "/config")
    public List<ConfigProperties> config(@RequestParam(value = "application", required = false) String application,
                                            @RequestParam(value = "label", required = false) String label,
                                            @RequestParam(value = "profile", required = false) String profile) {
        return configPropertiesDao.queryOneProfile(application, profile, label);
    }
}
